package com.wn.class30.service.impl;

import com.wn.class30.entity.Product;
import com.wn.class30.entity.ProductExample;
import com.wn.class30.mapper.ProductDao;
import com.wn.class30.service.WXProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class WXProductServiceImpl implements WXProductService {
    @Resource
    private ProductDao productDao;
    @Override
    //根据销量和类型降序查询
    public List<Product> queryProductByOrderandType(Integer productTypeid,String orderBy) {
        ProductExample productExample = new ProductExample();
        ProductExample.Criteria criteria = productExample.createCriteria();
        criteria.andProductTypeEqualTo(productTypeid);
        productExample.setOrderByClause(orderBy);
        List<Product> products = productDao.selectByExampleAndBusiness(productExample);
        return products;
    }

    @Override
    public List<Product> queryProductByOrderandSerach(String serach,String orderBy) {
        ProductExample productExample = new ProductExample();
        ProductExample.Criteria criteria = productExample.createCriteria();
        String searchLike="%"+serach+"%";
        criteria.andProductDescLike(searchLike);
        productExample.setOrderByClause(orderBy);
        List<Product> products = productDao.selectByExampleAndBusiness(productExample);
        return products;
    }



}

